import 'package:easydubbing/pages/upload.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

import 'index.dart';
import 'my.dart';

class HomePage extends StatefulWidget {
  final String title;
  HomePage({Key key, this.title}) : super(key: key);

  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
  int currentPage = 0;
  List pageList = [IndexPage(),UpLoadPage(), MyPage(), ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: this.pageList[this.currentPage],
      bottomNavigationBar: BottomNavigationBar(
        onTap: (int i) {
          setState(() {
            currentPage = i;
          });
        },
        currentIndex: currentPage,
        items: [
          BottomNavigationBarItem(
              activeIcon: Container(
                height: 23,
                width: 23,
                child: Image(
                  image: AssetImage('assets/images/index.png'),
                  fit: BoxFit.fill,
                ),
              ),
              title: Text(
                '首页',
                style: TextStyle(
                    color: currentPage == 0 ? Colors.deepPurple : Colors.black,
                    fontSize: 10),
              ),
              icon: Container(
                height: 21,
                width: 21,
                child: Image(
                  image: AssetImage('assets/images/index1.png'),
                  fit: BoxFit.fill,
                ),
              )
          ),
          BottomNavigationBarItem(
              activeIcon: Container(
                height: 23,
                width: 23,
                child: Image(
                  image: AssetImage('assets/images/upload.png'),
                  fit: BoxFit.fill,
                ),
              ),
              title: Text(
                '上传',
                style: TextStyle(
                    color: currentPage == 1 ? Colors.deepPurple: Colors.black ,
                    fontSize: 10),
              ),
              icon: Container(
                height: 21,
                width: 21,
                child: Image(
                  image: AssetImage('assets/images/upload.png'),
                  fit: BoxFit.fill,
                ),
              )
          ),
          BottomNavigationBarItem(
              activeIcon: Container(
                height: 23,
                width: 23,
                child: Image(
                  image: AssetImage('assets/images/my.png'),
                  fit: BoxFit.fill,
                ),
              ),
              title: Text(
                '我的',
                style: TextStyle(
                    color: currentPage == 2 ? Colors.deepPurple: Colors.black,
                    fontSize: 11),
              ),
              icon: Container(
                height: 21,
                width: 21,
                child: Image(
                  image: AssetImage('assets/images/my1.png'),
                  fit: BoxFit.fill,
                ),
              )
          ),
        ],
      ),
    );
  }

//  List<Tab> tabs = [
//    Tab(
//      text: "首页",
//    ),
//    Tab(
//      text: "上传",
//    ),
//    Tab(
//      text: "我的",
//    ),
//  ];
//  TabController _tabController;
//
//  @override
//  void initState() {
//    _tabController = TabController(length: 3, vsync: this);
//    super.initState();
//  }
//
//  @override
//  Widget build(BuildContext context) {
//    return Scaffold(
//      body: TabBarView(
//        controller: _tabController,
//        children: [
//          Center(
//            child: Text("首页"),
//          ),
//          Center(
//            child: Text("上传"),
//          ),
//          Center(
//            child: Text("我的"),
//          ),
//        ],
//      ),
//      bottomNavigationBar: Container(
//        height: 50,
//        color: Color(0xFFFFFF),
//        child: TabBar(
//          tabs: tabs,
//          controller: _tabController,
//        ),
//      ),
//    );
//  }
}
